package cn.eshore.bnet.bpm.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

public class FileUtil {
    public static String readFile2String(final String processDefFile)
            throws UnsupportedEncodingException, IOException {
        InputStream process = FileUtil.class
                .getResourceAsStream(processDefFile);
        InputStreamReader reader = new InputStreamReader(process, "UTF-8");
        char[] processChars = new char[1024];
        StringBuffer sb = new StringBuffer();
        int length = 0;
        while ((length = reader.read(processChars)) > -1) {
            sb.append(processChars, 0, length);
        }
        reader.close();
        process.close();
        final String processDefString = sb.toString();
        return processDefString;
    }
}
